package ArrayList;
/*
*     存储对象
* #内部类的简单测试
* */
import java.util.ArrayList;

public class ArrayList2 {
    public static void main(String[] args) {
        ArrayList<Studenta> list = new ArrayList<>();
        ArrayList2.Studenta a = new ArrayList2().new Studenta(17,"张三");
        ArrayList2.Studenta b = new ArrayList2().new Studenta(18,"李四");
        ArrayList2.Studenta c = new ArrayList2().new Studenta(19,"狗五");

        list.add(a);
        list.add(b);
        list.add(c);

        for (int i = 0; i < list.size(); i++) {
            Studenta stu = list.get(i);
            System.out.println("姓名：" + stu.name + "年龄：" + stu.age);
        }
    }

    public class Studenta{
        int age;
        String name;

        public Studenta(int age, String name) {
            this.age = age;
            this.name = name;
        }
    }
}

